package top.jnaw.jee.platform.controller.basics.extend;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import top.jnaw.jee.platform.Consts;
import top.jnaw.jee.platform.Consts.Result;
import top.jnaw.jee.platform.model.Kcgl;
import top.jnaw.jee.platform.model.KcglUser;
import top.jnaw.jee.platform.model.Steps;
import top.jnaw.jee.utils.ModelResult;
import top.jnaw.jee.utils.Strings;

public class signController extends Controller {

  public void list() {
    JSONObject req = Strings.toJSONObject(this);
    final int page = Strings.getInt(req, "page", Consts.DEFAULT_PAGE);
    final int size = Strings.getInt(req, "size", Consts.DEFAULT_PAGE_SIZE);
    final String keyWord = Strings.getString(req, "keyWord", "");
    renderJson(Strings
        .formatJsonDateTime(
            Strings.formatPage(KcglUser.list(page, size, keyWord))));
  }

  public void check() {
    ModelResult result = new ModelResult(Result.kBadParam);
    JSONObject req = Strings.toJSONObject(this);
    final int kid = Strings.getInt(req, "kid", Consts.DEFAULT_BAD_ID);
    final String openid = Strings.getString(req, "openid", "");
    final String status = Strings.getString(req, "status", "");
    if (kid >= 0 && StrKit.notBlank(openid, status)) {
      result = KcglUser.check(kid, openid, status);
    }
    renderJson(result.toJson());
  }


}
